<template>
  <div class="container vh-100 d-flex justify-content-center align-items-center pb-5">
    <Card title="欢迎登陆" class="border-0" header-class="bg-white" footer-class="bg-white">
      <template v-slot:header>
        <h3 class="card-title">欢迎登录</h3>
      </template>
      <CardForm btn-text="登 录" @click="login" key="login"/>
      <template v-slot:footer>
        <router-link class="btn btn-linke text-secondary" to="/regist">如果您未注册账户，请点击此处注册</router-link>
      </template>
    </Card>
  </div>
</template>
<script>
import Card from "@/components/Card";
import CardForm from "@/components/CardForm";

export default {
  name: "Login",
  components: {
    Card,
    CardForm
  },
  methods: {
    login(username, password) {
      let user = this.$store.state.user;
      if (username == user.username && password == user.password) {
        this.$router.push({ path: "/" });
      } else {
        alert("登陆失败");
      }
    }
  }
};
</script>